<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Output a BMP image to browser or file</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.imageavif.html">« imageavif</a></li>
      <li style="float: right;"><a href="function.imagechar.html">imagechar »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.image.html">GD 和图像处理 函数</a></li>
    <li>Output a BMP image to browser or file</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.imagebmp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagebmp</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">imagebmp</span> &mdash; <span class="dc-title">Output a BMP image to browser or file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagebmp-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagebmp</strong></span>(<span class="methodparam"><span class="type"><a href="class.gdimage.html" class="type GdImage">GdImage</a></span> <code class="parameter">$image</code></span>, <span class="methodparam"><span class="type"><span class="type">resource</span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$file</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$compressed</code><span class="initializer"> = <strong><code>true</code></strong></span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Outputs or saves a BMP version of the given <code class="parameter">image</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagebmp-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>

<code class="parameter">image</code></dt>
<dd>
<p class="para">由图象创建函数(例如<span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>)返回的 
<span class="classname"><a href="class.gdimage.html" class="classname">GdImage</a></span> 对象。</p></dd>

    
     <dt>
<code class="parameter">file</code></dt>

     <dd>

      <p class="para">文件保存的路径或者已打开的流资源（此方法返回后自动关闭该流资源），如果未设置或为 <strong><code>null</code></strong>，将会直接输出原始图象流。</p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        <strong><code>null</code></strong> is invalid if the <code class="parameter">compressed</code> arguments is
        not used.
       </p>
      </p></blockquote>
     </dd>

    
    
     <dt>
<code class="parameter">compressed</code></dt>

     <dd>

      <p class="para">
       Whether the BMP should be compressed with run-length encoding (RLE), or not.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagebmp-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
  <div class="caution"><strong class="caution">警告</strong><p class="simpara">如果 libgd 输出图像失败，函数会返回 <strong><code>true</code></strong>。</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagebmp-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">image</code> expects a <span class="classname"><a href="class.gdimage.html" class="classname">GdImage</a></span>
  instance now; previously, a <span class="type">resource</span> was expected.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       The type of <code class="parameter">compressed</code> is <span class="type">bool</span> now; formerly it was <span class="type">int</span>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>



 <div class="refsect1 examples" id="refsect1-function.imagebmp-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2629">
    <p><strong>示例 #1 Saving a BMP file</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;blank&nbsp;image&nbsp;and&nbsp;add&nbsp;some&nbsp;text<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">120</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text_color&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">233</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">14</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">91</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #DD0000">'BMP&nbsp;with&nbsp;PHP'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Save&nbsp;the&nbsp;image<br /></span><span style="color: #0000BB">imagebmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'php.bmp'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Free&nbsp;up&nbsp;memory<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>